﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using System.Web.Mvc.Html;

namespace Peak.Web.Controllers.HtmlExtentions
{
  public static class PopupExtension
  {
    public static MvcHtmlString PopupLink(this HtmlHelper html, string label, string popupId)
    {
      string linkId = Guid.NewGuid().ToString();
      TagBuilder a = new TagBuilder("a");
      a.Attributes.Add("id",linkId);      
      a.Attributes.Add("href", "#");
      a.Attributes.Add("onClick", "Popup.show('"+popupId+"','"+linkId+"','below left',{'constrainToScreen':true});return false;");
      a.InnerHtml = label;
      
      return MvcHtmlString.Create(a.ToString());
    }

    public static MvcHtmlString PopupDropDownButton(this HtmlHelper html, string popupId)
    {
      string linkId = Guid.NewGuid().ToString();
      TagBuilder button = new TagBuilder("img");
      button.Attributes.Add("id", linkId);
      button.Attributes.Add("class", "down-arrow");
      button.Attributes.Add("onClick", "Popup.show('" + popupId + "','" + linkId + "','below left',{'constrainToScreen':true});return false;");
      
      return MvcHtmlString.Create(button.ToString());
    }


    public static MvcHtmlString PopupButton(this HtmlHelper html, string label, string popupId)
    {
      string linkId = Guid.NewGuid().ToString();
      TagBuilder button = new TagBuilder("button");
      button.Attributes.Add("id", linkId);       
      button.Attributes.Add("onClick", "Popup.show('" + popupId + "','" + linkId + "','below left',{'constrainToScreen':true});return false;");
      button.InnerHtml = label;

      return MvcHtmlString.Create(button.ToString());
    }
  }
}
